package com.homework.factory;

import com.homework.factory.impl.NativeCodeSandBoxFactory;
import com.homework.factory.impl.RemoteCodeSandBoxFactory;
import com.homework.factory.impl.ThirdPartyCodeSandBoxFactory;

/**
 * @Author : Zan
 * @Create : 2024/6/16 14:07
 * @ClassName : Client
 * @Description : 创建者模式 —— 工厂模式的使用
 */
public class Client {
    public static void main(String[] args) {
        // 创建工厂实现类
        CodeSandBoxFactory factory = new NativeCodeSandBoxFactory();
        // 创建本地代码沙箱实例
        CodeSandBox codeSandBox = factory.newCodeSandBoxInstance();
        codeSandBox.executeCode();

        factory = new RemoteCodeSandBoxFactory();
        // 创建远程Docker代码沙箱实例
        codeSandBox = factory.newCodeSandBoxInstance();
        codeSandBox.executeCode();

        factory = new ThirdPartyCodeSandBoxFactory();
        // 创建第三方代码沙箱实例
        codeSandBox = factory.newCodeSandBoxInstance();
        codeSandBox.executeCode();

    }
}
